//
//  XMGEssenceViewController.m
//  BuDeJie
//
//  Created by Avril on 2020/3/15.
//  Copyright © 2020 Avril. All rights reserved.
//

#import "XMGEssenceViewController.h"
#import "UIBarButtonItem+Item.h"
@interface XMGEssenceViewController ()

@end

@implementation XMGEssenceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupNavBar];
}

-(void)setupNavBar{
    
    //设置导航条内容=》栈顶控制器的navationItem决定
        self.navigationItem.titleView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"MainTitle"]];
        //错误，导航条内容不能由导航控制器来设置,必须通过导航控制器的栈顶控制器来设置，所以导航控制器必须有根控制器
    //    self.navigationController.navigationItem.titleView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"MainTitle"]];
        
        /**
         bug:按钮点击范围扩大，不要让按钮扩大点击范围
         原因：把UIButton按钮包装成UIBarButtonItem就有问题。
         解决办法：先把UIButton加到一个view上，再把UIView加到UIBarButtonItem上。
         
         ****/

        //左边
        self.navigationItem.leftBarButtonItem =  [UIBarButtonItem itemWithImage:[UIImage imageNamed:@"nav_item_game_icon"] highImage:[UIImage imageNamed:@"nav_item_game_click_icon"] target:self action:@selector(gameClick)];
         
        //右边
       UIBarButtonItem *item =  [UIBarButtonItem itemWithImage:[UIImage imageNamed:@"navigationButtonRandom"] highImage:[UIImage imageNamed:@"navigationButtonRandomClick"] target:self action:@selector(randomClick)];
        self.navigationItem.rightBarButtonItem = item;
    
}

-(void)gameClick{
    
    NSLog(@"点击了游戏按钮");
}

-(void)randomClick{
    
    NSLog(@"点击了随机按钮");
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
